import { defineStore } from 'pinia'
import { postAdminListRequest } from '@/service/module/admin/admin'

interface Iadmindemo {
  iid: number
  title: string
  paper: string
  image: string
  path: string
  name: string
  content: string
}

export const useAdminSkillListStore = defineStore('adminskilllist', {
  state: () => ({
    admindemo: [] as Iadmindemo[],
    total: 0,
    iid: 0,
  }),

  getters: {
    // GET_TRAIN() {
    //     this.getTrainList()
    // }
  },
  actions: {
    //行测技巧列表数据
    async adminSkillListResultAction(adminlist: any) {
      const res = await postAdminListRequest(adminlist)
      // console.log(res.data.data.list, '行测技巧列表页数据')

      // this.admindemo = res.data.data.list
      // 使用三元运算符根据searchTitle判断数据来源
      this.admindemo = res.data.data.searchTitle
        ? res.data.data.list.searchAdminListData // 搜索时使用此字段
        : res.data.data.list // 非搜索时使用此字段
      this.total = res.data.data.total
      // console.log(this.admindemo, '行测技巧列表页数据')
    },
  },
  // persist: true,
})
